<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>第一节课</title>
		<style type="text/css">
			/*去除原来样式*/
			
			* {
				padding: 0;
				margin: 0;
			}
			
			.container {
				width: 100vw;
				height: 100vh;
				display: flex;
				/*
				 * 将边框设置在中间
				 */
				align-items: center;
				justify-content: center;
			}
			
			canvas {
				width: 500px;
				height: 500px;
				border: 1px solid #333333;
			}
		</style>
	</head>

	<body>
		<div class="container">
			<canvas id="canvas" width="500" height="500"></canvas>
		</div>
	</body>

	<script>
		
		window.onload = function() {
			//let oCanvas = document.getElementById('canvas');
			let oCanvas = document.getElementById("canvas");
			let pen = oCanvas.getContext("2d");

			/*pen.lineWidth = "10";
			pen.strokeStyle = "red";
			pen.moveTo(100,100);
			pen.lineTo(200,100);
			pen.stroke();
			
			pen.beginPath();
			pen.lineWidth = "10";
			pen.strokeStyle = "yellow";
			pen.moveTo(100,300);
			pen.lineTo(200,300);
			pen.stroke();*/
			
			/*pen.arc(100,100,50,Math.PI/180*(-90),Math.PI/180*90,false);
			pen.closePath();
			pen.stroke();
			
			pen.beginPath();
			pen.arc(300,100,50,Math.PI/180*(-90),Math.PI/180*90,false);
			pen.closePath();
			pen.strokeStyle = "aqua"
			pen.stroke();
			*/
			
			//这个点的坐标，如果这个点在路径中，就返回true，否则就返回false
			//isPointInPath(x,y);
			pen.fillStyle = "red"
			pen.lineWidth = "10"
			pen.strokeStyle="royalblue"
			pen.rect(100,200,100,100);
			pen.stroke();
			pen.fill();
			
			if(pen.isPointInPath(150,240)){
				alert("在路径中");
			}else{
				alert("不在路径中");
			}
			
		}
	</script>

</html>